<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
<link rel="Start" href="index.html">
<link rel="previous" href="Semantic.html">
<link rel="next" href="Syntaxtree.html">
<link rel="Up" href="index.html">
<link title="Index of types" rel=Appendix href="index_types.html">
<link title="Index of exceptions" rel=Appendix href="index_exceptions.html">
<link title="Index of values" rel=Appendix href="index_values.html">
<link title="Index of class attributes" rel=Appendix href="index_attributes.html">
<link title="Index of class methods" rel=Appendix href="index_methods.html">
<link title="Index of classes" rel=Appendix href="index_classes.html">
<link title="Index of modules" rel=Appendix href="index_modules.html">
<link title="Commands" rel="Chapter" href="Commands.html">
<link title="Declaration" rel="Chapter" href="Declaration.html">
<link title="Exceptions" rel="Chapter" href="Exceptions.html">
<link title="Expressions" rel="Chapter" href="Expressions.html">
<link title="Intermediate" rel="Chapter" href="Intermediate.html">
<link title="Lexer" rel="Chapter" href="Lexer.html">
<link title="Main" rel="Chapter" href="Main.html">
<link title="Parser" rel="Chapter" href="Parser.html">
<link title="Print" rel="Chapter" href="Print.html">
<link title="Print_syntaxtree" rel="Chapter" href="Print_syntaxtree.html">
<link title="Semantic" rel="Chapter" href="Semantic.html">
<link title="Subroutines" rel="Chapter" href="Subroutines.html">
<link title="Syntaxtree" rel="Chapter" href="Syntaxtree.html">
<link title="Target" rel="Chapter" href="Target.html"><title>Subroutines</title>
</head>
<body>
<div class="navbar"><a href="Semantic.html">Previous</a>
&nbsp;<a href="index.html">Up</a>
&nbsp;<a href="Syntaxtree.html">Next</a>
</div>
<center><h1>Module <a href="type_Subroutines.html">Subroutines</a></h1></center>
<br>
<pre><span class="keyword">module</span> Subroutines: <code class="code">sig</code> <a href="Subroutines.html">..</a> <code class="code">end</code></pre>Contains the functions to create the procedure/function table<br>
<hr width="100%">
<br>
Contains the functions to create the procedure/function table<br>
<pre><span class="keyword">val</span> <a name="VALjointable"></a><a href="code_VALSubroutines.jointable.html">jointable</a> : <code class="type">('a, 'b) Hashtbl.t -> ('a, 'b) Hashtbl.t -> ('a, 'b) Hashtbl.t</code></pre><div class="info">
Used to join two Hashtable into a single one<br>
</div>
<pre><span class="keyword">val</span> <a name="VALconvertList"></a><a href="code_VALSubroutines.convertList.html">convertList</a> : <code class="type"><a href="Syntaxtree.html#TYPEparam">Syntaxtree.param</a> list -> <a href="Syntaxtree.html#TYPEdec">Syntaxtree.dec</a> list</code></pre><div class="info">
Converts a param list into a dec list<br>
<b>Returns</b> The converted list<br>
</div>
<div class="param_info"><code class="code">plist</code> : The param list</div>
<pre><span class="keyword">val</span> <a name="VALgenParamTable"></a><a href="code_VALSubroutines.genParamTable.html">genParamTable</a> : <code class="type"><a href="Syntaxtree.html#TYPEdec">Syntaxtree.dec</a> list -> <a href="Intermediate.html#TYPEdec_table">Intermediate.dec_table</a> -> <a href="Intermediate.html#TYPEdec_table">Intermediate.dec_table</a></code></pre><div class="info">
Generate the Hashtable with the declaration of the parameters<br>
<b>Returns</b> The updated table of parameters<br>
</div>
<div class="param_info"><code class="code">p</code> : The declaration list of the parameters</div>
<div class="param_info"><code class="code">pdect</code> : The dec_table for the parameters</div>
<pre><span class="keyword">val</span> <a name="VALgenSubroutine"></a><a href="code_VALSubroutines.genSubroutine.html">genSubroutine</a> : <code class="type"><a href="Syntaxtree.html#TYPEide">Syntaxtree.ide</a> -><br>       <a href="Syntaxtree.html#TYPEdec">Syntaxtree.dec</a> list -><br>       <a href="Syntaxtree.html#TYPEdec">Syntaxtree.dec</a> list -><br>       <a href="Intermediate.html#TYPEdec_table">Intermediate.dec_table</a> -><br>       <a href="Intermediate.html#TYPEproc_table">Intermediate.proc_table</a> -><br>       <a href="Syntaxtree.html#TYPEcmd">Syntaxtree.cmd</a> -><br>       <a href="Intermediate.intermediateCode.html">Intermediate.intermediateCode</a> -><br>       <a href="Intermediate.html#TYPEreturn">Intermediate.return</a> -> <a href="Intermediate.html#TYPEproc_entry">Intermediate.proc_entry</a></code></pre><div class="info">
Generates the Subroutine entry for the Hashtable, after creating an Hashtable containing all the declarations of 
    the local variables and the parameters; then is checked the semantic of the subroutine's body and finally the 
    intermediate code is generated and saved. To do this, a new FunUtils class is created and substituted to the 
    present one, in order to have new variables for offsets and labels, but not registers (which are common for all 
    functions/procedures/main )<br>
<b>Returns</b> The built entry for the subroutine<br>
</div>
<div class="param_info"><code class="code">id</code> : The ide of the procedure</div>
<div class="param_info"><code class="code">pdeclist</code> : The dec list of the parameters</div>
<div class="param_info"><code class="code">dlist</code> : The local variables dec list</div>
<div class="param_info"><code class="code">dect</code> : The global variables declarations table</div>
<div class="param_info"><code class="code">proct</code> : The subroutines table</div>
<div class="param_info"><code class="code">c</code> : The body of the subroutine</div>
<div class="param_info"><code class="code">ic</code> : The intermediateCode class instance</div>
<div class="param_info"><code class="code">r</code> : The return type of the subroutine</div>
<pre><span class="keyword">val</span> <a name="VALgenSub"></a><a href="code_VALSubroutines.genSub.html">genSub</a> : <code class="type"><a href="Syntaxtree.html#TYPEproc">Syntaxtree.proc</a> -><br>       <a href="Intermediate.html#TYPEdec_table">Intermediate.dec_table</a> -><br>       <a href="Intermediate.html#TYPEproc_table">Intermediate.proc_table</a> -> <a href="Intermediate.intermediateCode.html">Intermediate.intermediateCode</a> -> unit</code></pre><div class="info">
Builds the Building entry for the Hashtable and then replace it with the Subroutine entry, which is build by the genSubruotine method.
    This is done in order to avoid errors with recursive calls, because until the entry is created, the function call raises 
    a Not_found exception. In the Building entry there are only the informations to check semantic errors.<br>
<b>Returns</b> The updated subroutines table<br>
</div>
<div class="param_info"><code class="code">p</code> : The subroutine to create</div>
<div class="param_info"><code class="code">dect</code> : The declaration table</div>
<div class="param_info"><code class="code">proct</code> : The subroutines table</div>
<div class="param_info"><code class="code">ic</code> : The intermediatecCode class instance</div>
<pre><span class="keyword">val</span> <a name="VALgenSubTable"></a><a href="code_VALSubroutines.genSubTable.html">genSubTable</a> : <code class="type"><a href="Syntaxtree.html#TYPEproc">Syntaxtree.proc</a> list -><br>       <a href="Intermediate.html#TYPEdec_table">Intermediate.dec_table</a> -><br>       <a href="Intermediate.html#TYPEproc_table">Intermediate.proc_table</a> -><br>       <a href="Intermediate.intermediateCode.html">Intermediate.intermediateCode</a> -> <a href="Intermediate.html#TYPEproc_table">Intermediate.proc_table</a></code></pre><div class="info">
Generate the subroutines table from the proc list<br>
<b>Returns</b> The updated subroutines table<br>
</div>
<div class="param_info"><code class="code">procl</code> : The proc list</div>
<div class="param_info"><code class="code">dect</code> : The declarations table</div>
<div class="param_info"><code class="code">table</code> : The subroutines table</div>
<div class="param_info"><code class="code">ic</code> : The intermediateCode class instance</div>
</body></html>